unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, RzButton, StdCtrls, Mask, RzEdit, rtcInfo, rtcConn, rtcTcpSrv;

type
  TForm1 = class(TForm)
    Edit_1: TRzEdit;
    Edit_2: TRzEdit;
    TcpServer_1: TRtcTcpServer;
    ChkBox_1: TCheckBox;
    procedure TcpServer_1ListenStart(Sender: TRtcConnection);
    procedure TcpServer_1DataReceived(Sender: TRtcConnection);
    procedure ChkBox_1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.TcpServer_1ListenStart(Sender: TRtcConnection);
begin
  Caption:='Listen Start';
end;

procedure TForm1.TcpServer_1DataReceived(Sender: TRtcConnection);
var
  ReadA:string;
  NumbA:Integer;
begin
  if Sender.inMainThread then
  begin
    ReadA:=Sender.Read;
//    NumbA:=StrToIntDef(ReadA,-1);
//    NumbA:=NumbA+2;
    Sender.Write('NORESPOND');
    Sender.Disconnect;
  end else
  begin
    Sender.Sync(TcpServer_1DataReceived);
  end;  
end;

procedure TForm1.ChkBox_1Click(Sender: TObject);
begin
  TcpServer_1.ServerAddr:=Trim(Edit_1.Text);
  TcpServer_1.ServerPort:=Trim(Edit_2.Text);
  TcpServer_1.MultiThreaded:=True;
  if ChkBox_1.Checked then
  begin
    TcpServer_1.Listen(True);
  end else
  begin
    TcpServer_1.StopListen;
  end;
end;

end.
